package com.d3works.apps.hr.service.bankorder;

import com.d3works.apps.account.db.repo.InvoiceRepository;
import com.d3works.apps.account.db.repo.InvoiceTermRepository;
import com.d3works.apps.bankpayment.db.repo.BankOrderLineOriginRepository;
import com.d3works.apps.bankpayment.service.bankorder.BankOrderLineOriginServiceImpl;
import com.d3works.apps.hr.db.Expense;
import com.d3works.db.Model;
import com.d3works.dms.db.repo.DMSFileRepository;
import com.google.inject.Inject;
import java.time.LocalDate;

public class BankOrderLineOriginServiceHRImpl extends BankOrderLineOriginServiceImpl {

  @Inject
  public BankOrderLineOriginServiceHRImpl(
      BankOrderLineOriginRepository bankOrderLineOriginRepository,
      InvoiceTermRepository invoiceTermRepository,
      InvoiceRepository invoiceRepository,
      DMSFileRepository dmsFileRepository) {
    super(
        bankOrderLineOriginRepository, invoiceTermRepository, invoiceRepository, dmsFileRepository);
  }

  @Override
  protected String computeRelatedToSelectName(Model model) {

    if (model instanceof Expense) {

      return ((Expense) model).getExpenseSeq();

    } else {

      return super.computeRelatedToSelectName(model);
    }
  }

  @Override
  protected LocalDate computeRelatedToSelectDate(Model model) {

    if (model instanceof Expense) {

      return ((Expense) model).getValidationDate();

    } else {

      return super.computeRelatedToSelectDate(model);
    }
  }

  @Override
  protected LocalDate computeRelatedToSelectDueDate(Model model) {

    if (model instanceof Expense) {

      return ((Expense) model).getValidationDate();

    } else {

      return super.computeRelatedToSelectDueDate(model);
    }
  }
}
